package com.ml.mall.api.analytics;

import com.ml.mall.api.BaseController;
import com.ml.mall.bean.base.ApiRestResult;
import com.ml.mall.bean.req.BaseDateRangeReq;
import com.ml.mall.bean.req.admin.category.AdminCategoryQueryOneReq;
import com.ml.mall.bean.req.admin.category.AdminCategoryQueryPageReq;
import com.ml.mall.bean.req.admin.coupon.CouponQueryOneReq;
import com.ml.mall.bean.req.admin.coupon.CouponQueryPageReq;
import com.ml.mall.bean.req.admin.coupon.CouponQueryUseNumReq;
import com.ml.mall.bean.req.admin.purchase.PurchaseQueryReportPageReq;
import com.ml.mall.bean.req.admin.purchase.PurchaseQuerySpentCategoryReq;
import com.ml.mall.bean.req.admin.variant.VariantQueryOneReq;
import com.ml.mall.bean.req.admin.variant.VariantQueryPageReq;
import com.ml.mall.bean.req.supplier.SupplierPurchaseQueryOneReportReq;
import com.ml.mall.consts.CommonConsts;
import com.ml.mall.consts.PermissionConst;
import com.ml.mall.service.AnalyticsCouponService;
import com.ml.mall.service.AnalyticsSupplierService;
import com.ml.mall.utils.DateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * Created by kyyang on 2021/6/8 21:39
 */
@Api(tags = "优惠券分析")
@RestController
@RequestMapping("/coupon")
@Slf4j
public class AnalyticsCoupponController extends BaseController {
    @Autowired
    private AnalyticsCouponService analyticsCouponService;

    @RequestMapping(method = RequestMethod.POST, path = "/day_detail")
    @ApiOperation("查询某一优惠券的天明细")
//    @RequiresPermissions(PermissionConst.COUPON_DAY_DETAIL)
    public ApiRestResult queryCouponDayDetail(@Valid @RequestBody CouponQueryUseNumReq req) {
        return ApiRestResult.ok(analyticsCouponService.selectDayUseNumByCouponCodeAndTime(req));
    }

    @RequestMapping(method = RequestMethod.POST, path = "/coupon_order_page")
    @ApiOperation("查询优惠券订单分页")
//    @RequiresPermissions(PermissionConst.COUPON_ORDER_PAGE)
    public ApiRestResult queryCouponOrderPage(@Valid @RequestBody CouponQueryPageReq req){
        return ApiRestResult.ok(analyticsCouponService.selectOrderByCouponCode(req));
    }
}
